package com.keyancompany.zhongbaopingtai.weight;

import android.content.Context;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ListView;
import android.widget.TextView;

import com.keyancompany.zhongbaopingtai.R;
import com.keyancompany.zhongbaopingtai.adapter.FenLeiAdapter;
import com.keyancompany.zhongbaopingtai.adapter.TeamAdapter;
import com.keyancompany.zhongbaopingtai.model.Labels;
import com.keyancompany.zhongbaopingtai.utils.ScreenUtils;
import com.keyancompany.zhongbaopingtai.utils.T;

import java.util.List;

import butterknife.Bind;
import butterknife.OnClick;

/**
 * Created by firefox on 2016/6/16.
 */
public class SelectFenLeiPopup extends MenuPopuWindow {

    @Bind(R.id.team_select_left)
    ListView teamSelectLeft;
    @Bind(R.id.team_select_right)
    ListView teamSelectRight;
    @Bind(R.id.select_sure)
    TextView sure;
    List<Labels> labels;
    FenLeiAdapter teamAdapter;

    public SelectFenLeiPopup(Context context) {
        super(context);
    }

    public void setLabels(List<Labels> labelses) {
        if (teamAdapter != null)
            teamAdapter.addAllAfter(labelses);
    }

    @Override
    public void setUpViews() {

//        teamSelectLeft = (NoScorllerListView) findViewById(R.id.team_select_left);
//        teamSelectRight = (NoScorllerListView) findViewById(R.id.team_select_right);
        teamSelectRight.setVisibility(View.GONE);
        sure.setVisibility(View.GONE);
        teamAdapter = new FenLeiAdapter(context);
//        teamSelectLeft.setAdapter(teamAdapter);
        teamSelectLeft.setAdapter(teamAdapter);
    }

    @Override
    public void setUpListener() {
        teamSelectLeft.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
                if (cliclSureListener != null)
                    cliclSureListener.clickSureLinstener(teamAdapter.getItem(i).getId(),
                            teamAdapter.getItem(i).getText(), teamAdapter.getItem(i).getParentId());
            }
        });

    }

    @OnClick(R.id.select_sure)
    public void clickSure(View view) {
        T.showShort(context, "确认");
        dismiss();
        if (cliclSureListener != null)
            cliclSureListener.clickSureLinstener(new String[]{});
    }

    @Override
    public int getAnimationStyle() {
        return 0;
    }

    @Override
    public int getResView() {
        return R.layout.popup_team_select;
    }

    @Override
    public void updateView(View contentView) {
        setWidth(ScreenUtils.getScreenWidth(context) * 4 / 5);
        setHeight(ScreenUtils.getScreenHeight(context) * 2 / 3);
    }
}
